/*
 * @Author: humengchuan 531537052@qq.com
 * @Date: 2023-12-27 11:14:31
 * @LastEditors: humengchuan 531537052@qq.com
 * @LastEditTime: 2024-06-25 09:15:01
 * @FilePath: \project\node-project\website-admin\vite.config.ts
 * @Description: 
 */
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import path from 'path'

// https://vitejs.dev/config/
export default defineConfig(() => 
{ 
  return {
    plugins: [vue(),
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
    ],
    resolve: {
      alias: {
        "~": path.resolve(__dirname, "./"),
        "@": path.resolve(__dirname, "./src")
      }
    },
    server: {
      proxy: {
        '/api' : {
          target: 'http://localhost:3000',
          rewrite: (path) => path.replace(/^\/api/, ''),
          changeOrigin: true, // 允许跨域
          logLevel: 'debug'
        }
      }
    },
  }
})
